﻿<UserControl x:Class="ProTemplate.UserControls.CustomControl.ContainerInputForm"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:sdk="http://schemas.microsoft.com/winfx/2006/xaml/presentation/sdk"
    xmlns:input="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Input"
    xmlns:telerikGridView="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls.GridView"
    xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation"
    mc:Ignorable="d"
    d:DesignHeight="300" d:DesignWidth="720">
    <UserControl.Resources>
        <Style TargetType="TextBlock" x:Key="AddDeclarationLable">
            <Setter Property="VerticalAlignment" Value="Center" />
            <Setter Property="Width" Value="70" />
            
        </Style>
        <Style TargetType="TextBox" x:Key="AddDeclarationInputBoxShort">
            <Setter Property="VerticalAlignment" Value="Center" />
            <Setter Property="Width" Value="130" />
            <Setter Property="Margin" Value="0,0,5,0" />
        </Style>
    </UserControl.Resources>

    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="*" />
            <RowDefinition Height="Auto" />
        </Grid.RowDefinitions>
        <telerikGridView:RadGridView telerik:Theming.Theme="Office_Blue" Style="{StaticResource CommonRadGridView}" ShowGroupPanel="False" 
                                     ItemsSource="{Binding Path=Items, Source={StaticResource DeclarationContainerViewModel}}">
            <telerikGridView:RadGridView.Columns>
                <telerik:GridViewDataColumn Header="序号" DataMemberBinding="{Binding Index}" IsFilterable="False" />
                <telerik:GridViewDataColumn Header="集装箱号" DataMemberBinding="{Binding Number}" IsFilterable="False" Width="100" />
                <telerik:GridViewDataColumn Header="规格" DataMemberBinding="{Binding Model}" IsFilterable="False" Width="50" />
                <telerik:GridViewDataColumn Header="自重(公斤)" DataMemberBinding="{Binding Weight}" IsFilterable="False" Width="100" />
                <telerikGridView:GridViewDataColumn Header=""  IsReorderable="False" IsFilterable="False">
                    <telerikGridView:GridViewDataColumn.CellTemplate>
                        <DataTemplate>
                            <StackPanel Orientation="Horizontal">
                                <telerik:RadButton x:Name="btnEdit" Click="btnEdit_Click" IsEnabled="{Binding Index, Converter={StaticResource DataRowButtonIsEnabledConverter}}">
                                    <Image Source="/ProTemplate;component/Images/Icons/edit.png" ToolTipService.ToolTip="编辑" Style="{StaticResource ToolBarIconStyle}" />
                                </telerik:RadButton>
                                <telerik:RadButton x:Name="btnDelete" Click="btnDelete_Click" Margin="3 0" IsEnabled="{Binding Index, Converter={StaticResource DataRowButtonIsEnabledConverter}}">
                                    <Image Source="/ProTemplate;component/Images/Icons/delete.png" ToolTipService.ToolTip="删除" Style="{StaticResource ToolBarIconStyle}" />
                                </telerik:RadButton>
                            </StackPanel>
                        </DataTemplate>
                    </telerikGridView:GridViewDataColumn.CellTemplate>
                </telerikGridView:GridViewDataColumn>
            </telerikGridView:RadGridView.Columns>
        </telerikGridView:RadGridView>
        <Grid Grid.Row="1">
            <Grid.RowDefinitions>
                <RowDefinition Height="30" />
            </Grid.RowDefinitions>
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="Auto" />
                <ColumnDefinition Width="Auto" />
                <ColumnDefinition Width="Auto" />
                <ColumnDefinition Width="Auto" />
            </Grid.ColumnDefinitions>
            <StackPanel Grid.Column="0" Orientation="Horizontal">
                <TextBlock Text="集装箱号：" Style="{StaticResource AddDeclarationLable}" />
                <TextBox x:Name="tbNumber" Style="{StaticResource AddDeclarationInputBoxShort}" Text="{Binding Number, Mode=TwoWay, ValidatesOnExceptions=True, NotifyOnValidationError=True,UpdateSourceTrigger=Explicit}" />
            </StackPanel>
            <StackPanel Grid.Column="1" Orientation="Horizontal">
                <TextBlock Text="规格：" Style="{StaticResource AddDeclarationLable}" Width="40" />
                <TextBox x:Name="tbModel" Style="{StaticResource AddDeclarationInputBoxShort}" MaxLength="1" Text="{Binding Model}" />
            </StackPanel>
            <StackPanel Grid.Column="2" Orientation="Horizontal">
                <TextBlock Text="自重(公斤)：" Style="{StaticResource AddDeclarationLable}" />
                <TextBox x:Name="tbWeight" Style="{StaticResource AddDeclarationInputBoxShort}" Text="{Binding Weight}" />
            </StackPanel>

            <StackPanel x:Name="spAddContainer" Grid.Column="3" HorizontalAlignment="Left" VerticalAlignment="Center" Margin="5,0">
                <Button x:Name="btnAdd" Width="55" VerticalAlignment="Center" Height="20"  Content="添加" Click="btnAdd_Click" />
            </StackPanel>
            <StackPanel x:Name="spUpdateContainer" Orientation="Horizontal" Visibility="Collapsed" Grid.Column="3" HorizontalAlignment="Left" VerticalAlignment="Center" Margin="5,0">
                <Button x:Name="btnUpdate" Width="55" VerticalAlignment="Center" HorizontalAlignment="Left" Height="20"  Content="更新" Click="btnUpdate_Click" />
                <Button x:Name="btnCancel" Width="55" VerticalAlignment="Center" HorizontalAlignment="Left" Height="20"  Content="取消" Click="btnCancel_Click" />
            </StackPanel>
        </Grid>
    </Grid>
</UserControl>
